package com.merelyb.data.service.service.service.affpay;

import com.merelyb.data.service.common.MultiDataSourceContextHolder;
import com.merelyb.data.service.service.mybatis.bean.affpay.AffpayInfo;
import com.merelyb.data.service.service.mybatis.dao.affpay.AffpayInfoDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by LiM on 2017/12/15.
 */
@Service
public class AffpayInfoService {
    @Autowired
    AffpayInfoDao affpayInfoDao;


    /**
     * 查询数据
     *
     * @param affpayInfo
     * @return
     * @throws Exception
     */
    public List<AffpayInfo> queryAllList(AffpayInfo affpayInfo) throws Exception {
        return affpayInfoDao.queryAllList(affpayInfo, MultiDataSourceContextHolder.DATA_AFFPAY);
    }

    /**
     * 分页查询数据
     *
     * @param affpayInfo
     * @return
     */
    public List<AffpayInfo> queryListByLimit(AffpayInfo affpayInfo) {
        return affpayInfoDao.queryListByLimit(affpayInfo, MultiDataSourceContextHolder.DATA_AFFPAY);
    }

    /**
     * 新增单条数据
     *
     * @param affpayInfo
     * @throws Exception
     */
    public void addData(AffpayInfo affpayInfo) throws Exception {
        affpayInfoDao.addData(affpayInfo, MultiDataSourceContextHolder.DATA_AFFPAY);
    }

    /**
     * 批量新增数据
     *
     * @param affpayInfoList
     * @throws Exception
     */
    public void addData(List<AffpayInfo> affpayInfoList) throws Exception {
        affpayInfoDao.addData(affpayInfoList, MultiDataSourceContextHolder.DATA_AFFPAY);
    }

    /**
     * 更新数据
     *
     * @param affpayInfo
     * @throws Exception
     */
    public void updateData(AffpayInfo affpayInfo) throws Exception {
        affpayInfoDao.updateData(affpayInfo, MultiDataSourceContextHolder.DATA_AFFPAY);
    }

    /**
     * 更新数据状态
     *
     * @param affpayInfo
     * @throws Exception
     */
    public void deleteData(AffpayInfo affpayInfo) throws Exception {
        affpayInfoDao.deleteData(affpayInfo, MultiDataSourceContextHolder.DATA_AFFPAY);
    }

    /**
     * 统计数量
     *
     * @param affpayInfo
     * @return
     */
    public int getCount(AffpayInfo affpayInfo) {
        return affpayInfoDao.getCount(affpayInfo, MultiDataSourceContextHolder.DATA_AFFPAY);
    }

    /**
     * 获取最小支付类型
     * @param affpayInfo
     * @return
     * @throws Exception
     */
    public List<String> getMinPayType(AffpayInfo affpayInfo) throws Exception {
        return affpayInfoDao.getAllPayMinType(affpayInfo, MultiDataSourceContextHolder.DATA_AFFPAY);
    }

    /**
     * 根据编号查询数据
     * @param IdsList
     * @return
     * @throws Exception
     */
    public List<AffpayInfo> getAffpayInfoByIds(List<Long> IdsList) throws Exception{
        return affpayInfoDao.getAffpayInfoByIds(IdsList, MultiDataSourceContextHolder.DATA_AFFPAY);
    }
}
